package com.hackintosh.flyweight.web;

import java.util.HashMap;
import java.util.Map;

/**
 * @description：
 * @author：twislyn
 * @date：Created in 2021/05/14
 * @modified By：
 * @version: 1.0
 */
public class WebSiteFactory {
    private Map<String, WebSite> webSiteMap = new HashMap<>();

    public WebSite getWebSite(String key) {
        WebSite webSite = webSiteMap.get(key);
        if (webSite != null) {
            System.out.println("具体享元" + key + "已经存在，被成功获取！");
        } else {
            webSite = new ConcreteWebSite(key);
            webSiteMap.put(key, webSite);
        }
        return webSite;
    }
}
